home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-26 | 12.2 KB | 702 lines | [TEXT/sLiN] |
- !V3.0
- !
- !$ Use this script with Supra 14400bps and 9600bps fax modems.
- !$ Supports: voice, fax, and ARA incoming calls.
- !
- !$ Make sure that *Class 1* fax software is installed, and that
- !$ your modem has voice-capable ROMs.
- !
- !$ A hardware handshaking cable is required.
-
- ^2 Fax Software: = Enum("FaxSTF 2.x Class 1" = "0","FaxSTF 3.x/Faxilitate"="1","FaxSTF Class 2" = "2","Delrina"="3","4-Sight"="4") "0"
- ^3 Error Correction: = Bool("Enabled"="\N3","Disabled"="\N0") "\N0"
- ^4 Handshake wires: = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
- ! ------------------------------------------
- ! Resetting the modem:
- ! ------------------------------------------
- @HANGUP
- SerReset 19200,0,8,1
- HsReset 0,0,17,19,0,0
- Flush
- SetTries 2
- write "ATH0S0=0\r"
- Flush
-
- !
- ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
- ! to enter the command mode
- !
- @Label 1
- write "AT+VC=0\r"
- flush
- write "AT&F1V1\r"
- matchclr
- matchstr 1 2 "OK\r\n"
- matchread 20
- Chrdelay 1
- Write "+++"
- Chrdelay 0
- DtrClear
- SBreak
- DtrSet
-
- write "AT+VC=0\r"
- matchclr
- matchstr 1 1 "OK\r\n"
- matchread 10
- !
- Write "ATE0V1\r"
- Matchstr 1 1 "OK\r\n"
- Matchread 10
-
- write "ATH0\r"
- matchstr 1 1 "OK\r\n"
- matchread 10
- DecTries
- IfTries 0 1
- exit -6019
-
- @Label 2
- SerReset 19200,0,8,1
- Jsr 80
- Write "AT+FCLASS=0;+FAE=0\r"
- Jsr 100
- exit 0
-
-
- ! ------------------------------------------
- ! Receiving incoming calls
- ! ------------------------------------------
- @ANSWER
- SerReset 19200,0,8,1
- @Label 3
- Jsr 70
-
- ifOpen "Voice" 11
- !
- ! Waiting for Fax/ARA calls only (no Voice App running)
- Note "Voice Application is not running..."
-
- ! No Voice App running -- turn off caller ID
- Write "AT#CID=0\r"
- Jsr 100
-
- ! This would allow us to not go into AA mode if we could have more labels.
- ifOpen "ARA" 4
- IfOpen "Data" 4
- ifOpen "Fax" 4
- Note "No services active: the modem will not respond."
- Pause 600
- Jump 3
-
- ! Fax/Data only (no voice)
- @Label 4
- Jsr 130
- Jsr 55
- !
- ! Fetch the tube after S0 rings
- SetVar B "S0=2"
- GetCommand A "Fax" "S0"
- IfStr A 5 "S0=0"
- IfStr A 5 ""
- SetVar B "^A"
- @Label 5
- Write "AT^B\r"
- Jsr 100
- !
- ! Tell the modem to determine the type of the incoming call
- ! Switch to the "numeric" mode, if necessary
- SetVar A "1"
- Jsr 56
-
- !
- ! Everything is ready - let's sit and wait for a call
- Note "Waiting for a fax or ARA/Data call..."
- Jsr 175
- IfStr A 20 "Data"
- IfStr A 40 "Fax1"
- IfStr A 45 "Fax2"
- Jump 3
-
- ! ---------- Voice Mode ---------
- ! check to see if the voice code has been downloaded
- ! if not, tell PhonePro to download it.
- !
- @Label 11
- Note "Checking the modem..."
- Write "AT+VC=0\r"
- Jsr 120
- Write "AT+VC=1\r"
- MatchClr
- MatchStr 1 14 "OK\r\n"
- MatchStr 2 13 "ERROR\r\n"
- MatchRead 20
- Exit -6019
- !
- ! tell the Voice Tool to download the voice code
- !
- @Label 13
- Note "Downloading voice code to modem..."
- Pause 20
- QueueInput "\r\nLOAD\r\n"
- Attach "Voice" (Master)
-
- @Label 14
- Write "AT+VC=0\r"
- Jsr 100
-
- !
- ! sit and wait for a call for up to 30 seconds, then re-initiate the modem
- ! Get caller ID, if voice enabled
- !! QueueInput "\r\nGET_CALLER_ID_FLAG\r\n"
- !! Attach "Voice" (Master)
- !! SetVar B "^$"
- !! Write "AT#CID=^B\r"
- !! Jsr 100
-
- Note "Waiting for a Voice/Fax/ARA/Data call"
- MatchClr
- MatchStr 1 15 "RING\r\n"
- MatchRead 1800
- Jump 3
-
- @Label 15
- Note "Ring..."
- QueueInput "\r\nRING\r\n"
- Attach "Voice" (Master)
- Write "+++"
- Note "Switching from voice..."
-
- ! fall through if the call is not a voice call (as indicated by the telephone tool)
- !
- SetVar A "^$"
- SerReset 19200,0,8,1
- HsReset 0,0,17,19,0,0
- Jsr 80
-
- IfStr A 17 "Fax"
- IfStr A 18 "ARA"
- Exit -6019
-
- !
- ! Force to answer a Fax call
- !
- @Label 17
- Note "Answering a fax call..."
- SetVar A "0"
- Jsr 56
- Write "ATA\r"
- Jsr 175
- ifStr A 40 "Fax1"
- ifStr A 45 "Fax2"
- Write "\r"
- Exit -6019
-
- !
- ! Force to answer an ARA/Data call
- !
- @Label 18
- Note "Answering a data call..."
- Jsr 70
- ! Set the communication options:
- Jsr 55
- Write "AT+FAA=0;+FCLASS=0\r"
- Jsr 100
- Write "ATA\r"
- Jsr 180
- IfStr A 20 "Data"
- Write "\r"
- Exit -6019
-
- !
- ! Data connection has been established (we read "CONNECT")
- ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
- ! if it was an incoming call, put the "RING" before the "CONNECT"
- !
- @Label 20
- IfOpen "Data" 21
- Jump 30
- @Label 21
- IfOpen "ARA" 22
- Jump 35
- @Label 22
- Note "Waiting for an ARA frame"
- MatchClr
- MatchStr 1 23 "^$\r"
- MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
- MatchStr 3 29 "\01\27\02\29\01\02\01\06"
- MatchRead 40
- Jump 24
- @Label 23
- QueueInput "^$\r"
- @Label 24
- Note "Non-ARA call"
- Jump 35
-
- @Label 28
- Note "ARA 1.0 call"
- Jump 30
- @Label 29
- Note "ARA 2.0 call"
- Jump 30
-
- @Label 30
- QueueInput "\r\nCARRIER ^B\r\n"
- IfStr C 31 "NONE"
- QueueInput "\r\nREL\r\n"
- @Label 31
- IfOriginate 32
- QueueInput "\r\nRING\r\n"
- @Label 32
- Attach "ARA" (DTR)
-
- @Label 35
- GetSReg C "DATA" 4
- QueueInput "\r^CCONNECT ^B\r^C"
- ifOriginate 36
- QueueInput "\r^CRING\r^C"
- @Label 36
- Attach "Data" (DTR,Escape,Break,IdleLimit=60)
-
- !
- ! Fax Class 1 connection has been established
- ! Attach the "Fax" subPort
- @Label 40
- QueueInput "1\r"
- ifOriginate 41
- QueueInput "2\r"
- @Label 41
- IfStr 2 42 "0"
- Attach "Fax" (DTR,Reset)
- @Label 42
- Attach "Fax" (DTR,Reset(2400))
-
- !
- ! Fax Class 2 connection has been established
- ! Attach the "Fax" subPort
- @Label 45
- QueueInput "\r\n+FCON\r\n"
- ifOriginate 46
- QueueInput "\r\nRING\r\n"
- @Label 46
- IfStr 2 47 "2"
- Attach "Fax" (DTR)
- @Label 47
- Attach "Fax" (DTR,Reset)
-
- ! ------------------------------------------
- ! Originating a call through the "Voice" subport
- ! ------------------------------------------
- @ORIGINATE "Voice" ("\r\nBUSY\r\n")
- Note "PhonePro is originating a call ..."
- SerReset *
- HsReset *
- Attach "Voice" (Escape, Master)
- Exit -6019
-
-
-
- ! ------------------------------------------
- ! Originating a call through the "ARA" subport
- ! ------------------------------------------
- @ORIGINATE "ARA"
- Jsr 51
- Jump 30
-
- ! ------------------------------------------
- ! Originating a call through the "Data" subport
- ! ------------------------------------------
- @ORIGINATE "Data"
- Jsr 51
- Jump 35
-
- @Label 51
- SerReset 38400,0,8,1
- Jsr 80
- !
- ! Set the common options & Comm options
- Jsr 70
- Jsr 55
- !
- ! Prepare to receive all error result codes, dial the number
- Write "ATDT^1\r"
- Jsr 180
- IfStr A 103 "Data"
- Write "\r"
- Exit -6019
-
- ! ------------------------------------------
- ! Originating a call through the "Fax" subPort
- ! ------------------------------------------
- @ORIGINATE "Fax" ("\r\nBUSY\r\n")
- ! Clear the modem's magic memory
- Jsr 130
- SerReset *
- HsReset *
- Jsr 80
- Write "ATZ\r"
- Jsr 100
- Write "AT+VC=0\r"
- Jsr 120
- !
- ! Set the common options
- Jsr 70
-
- !
- ! Set the Fax mode
- SetVar A "2"
- Jsr 56
- Write "AT+VC=0\r"
- Jsr 120
-
- !
- ! Now emit all commands that the application has sent to that port,
- ! except "+FCLASS", etc
- !
- EmitClear "+FCLASS","V","E","S0"
- Jsr 60
-
- !
- ! Switch the verbos mode, if necesary
- !
- Jsr 58
-
- Write "ATD^1\r"
- Jsr 175
- HsReset *
- IfStr A 40 "Fax1"
- IfStr A 45 "Fax2"
- Write "\r"
- Exit -6019
-
- !
- ! Set the communication options:
- ! • \N0 &Q6: Normal connection (for ARA)
- ! • &K3: HW flow control (for ARA, Fax should not use a handshake on receiving)
- ! • W1: report connection speed
- !
- @Label 55
- Write "AT^3&K3W1\r"
- Jsr 100
- return
-
- !
- ! Tuning the fax mode
- @Label 56
- ifStr 2 57 "0"
- ifStr 2 57 "1"
- Write "AT+FCLASS=2\r"
- Jsr 100
- GetCommand A "Fax" "+FLID="
- Jsr 99
- Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
- Jsr 100
- GetCommand A "Fax" "+FDCC="
- Jsr 99
- GetCommand A "Fax" "+FBOR="
- Jsr 99
- ifStr A 103 "0"
- ifStr A 103 "2"
- Write "AT+FAA=1;+FCLASS=0\r"
- Jump 100
-
- @Label 57
- Write "AT&K4+FCLASS=1\r"
- Jsr 100
- ifStr A 103 "2"
- ifStr A 58 "0"
- Write "AT+FAE=1;+FCLASS=0\r"
- Jsr 100
- @Label 58
- ifStr 2 59 "0"
- ifStr 2 59 "1"
- return
- @Label 59
- Write "ATV0\r"
- Jump 110
-
- !
- ! This section emits all modem commands sent from the client application
- ! For each set of commands the "OK" answer is awaited
- !
- @Label 60
- EmitStart
- @Label 61
- EmitCommand 62
- Jsr 100
- Jump 61
- @Label 62
- return
- !
- ! This section initiates the modem before ANSWER and ORIGINATEs:
- ! extended responses + connect at the highest rate + speaker control +
- ! reset on Dtr drop + DCD valid
- ! Verbal responses mode, no echo
- !
- @Label 70
- Write "ATX4N1^4&C1V1E0\r"
- Jsr 100
- return
-
- !
- ! This section syncronize the modem after the serial port speed switching
- !
- @Label 80
- ChrDelay 1
- Write "\r\r"
- Pause 2
- Write "AT\r"
- ChrDelay 0
- Jsr 100
- return
- !
- ! Prepare to receive error result codes, send the dialing command and
- ! set the user's handshake mode
- !
- @Label 90
- MatchClr
- MatchStr 2 91 "NO DIALTONE\r\n"
- MatchStr 3 92 "BUSY\r\n"
- MatchStr 4 93 "NO CARRIER\r\n"
- MatchStr 5 94 "NO ANSWER\r\n"
- Write "ATD^1\r"
- HsReset *
- return
-
- @Label 91
- exit -6020
- @Label 92
- exit -6022
- @Label 93
- exit -6021
- @Label 94
- exit -6023
- !
- ! Processing the AT command:
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 99
- Write "AT^A\r"
- @Label 100
- MatchClr
- MatchStr 1 103 "\r\nOK\r\n"
- MatchStr 2 102 "\r\nERROR\r\n"
- @Label 101
- MatchRead 20
- @Label 102
- Exit -6019
- @Label 103
- return
-
- @Label 110
- MatchClr
- MatchStr 1 103 "0\r"
- MatchStr 2 102 "4\r"
- Jump 101
-
- @Label 120
- MatchClr
- MatchStr 1 103 "\r\nOK\r\n"
- MatchStr 2 103 "\r\nERROR\r\n"
- MatchRead 20
- Exit -6019
-
- !This zeros out a location in memory that
- !when cleared, enables STF to send/receive faxes.
- @Label 130
- MatchClr
- Write "AT!2000M\r"
- MatchStr 1 131 "\r\n2000: "
- MatchRead 20
- Jump 150
-
- @Label 131
- MatchClr
- Write "00"
- MatchStr 1 132 "\r\n2001: "
- MatchRead20
- Jump 150
-
- @Label 132
- MatchClr
- Write "00"
- MatchStr 1 133 "\r\n2002: "
- MatchRead 20
- Jump 150
-
- @Label 133
- MatchClr
- Write "00"
- MatchStr 1 134 "\r\n2003: "
- MatchRead 20
- Jump 150
-
- @Label 134
- MatchClr
- Write "00"
- MatchStr 1 135 "\r\n2004: "
- MatchRead 20
- Jump 150
-
- @Label 135
- MatchClr
- Write " "
- Jsr 100
-
- @Label 136
- MatchClr
- Write "AT!2007M\r"
- MatchStr 1 137 "\r\n2007: "
- MatchRead 20
- Jump 150
-
- @Label 137
- MatchClr
- Write "00"
- MatchStr 1 138 "\r\n2008: "
- MatchRead20
- Jump 150
-
- @Label 138
- MatchClr
- Write "00"
- MatchStr 1 139 "\r\n2009: "
- MatchRead20
- Jump 150
-
- @Label 139
- MatchClr
- Write "00"
- MatchStr 1 140 "\r\n200A: "
- MatchRead20
- Jump 150
-
- @Label 140
- MatchClr
- Write "00"
- MatchStr 1 141 "\r\n200B: "
- MatchRead20
- Jump 150
-
- @Label 141
- Write " "
- Jsr 100
- return
-
- @Label 150
- Note "Error clearing the modem's memory"
- Pause 50
- Write " "
- return
-
- !
- ! Connection. On exit, variables contain:
- ! ^A - NONE, Data or Fax
- ! ^B - connection speed
- ! ^C - PROTOCOL used
- @Label 175
- ifStr 2 190 "0"
- ifStr 2 190 "1"
- @Label 180
- SetVar C "NONE"
- MatchClr
- MatchStr 01 182 "RING\r\n"
- MatchStr 02 183 "PROTOCOL: ^$\r\n"
- MatchStr 03 184 "CARRIER ^$\r\n"
- MatchStr 04 185 "CONNECT ^$\r\n"
- MatchStr 05 186 "+FCON\r\n"
- MatchStr 06 91 "NO DIALTONE\r\n"
- MatchStr 07 92 "BUSY\r\n"
- MatchStr 08 93 "NO CARRIER\r\n"
- MatchStr 09 94 "NO ANSWER\r\n"
- @Label 181
- MatchRead 1200
- SetVar A "NONE"
- return
-
- @Label 182
- Note "Ring…"
- Jump 181
- @Label 183
- SetVar C "^$"
- Jump 181
- @Label 184
- SetVar B "^$"
- Jump 181
- @Label 185
- SetVar A "Data"
- return
- @Label 186
- SetVar A "Fax2"
- return
-
-
- @Label 190
- SetVar C "NONE"
- MatchClr
- MatchStr 01 191 "70\r"
- MatchStr 02 193 "77\r"
- MatchStr 03 193 "80\r"
-
- MatchStr 04 194 "47\r"
- MatchStr 05 195 "48\r"
- MatchStr 06 196 "49\r"
- MatchStr 07 197 "50\r"
- MatchStr 08 198 "51\r"
- MatchStr 09 199 "52\r"
-
- MatchStr 10 200 "16\r"
- MatchStr 11 200 "17\r"
- MatchStr 12 200 "18\r"
-
- MatchStr 13 192 "2\r"
- MatchStr 14 201 "1\r"
- MatchStr 15 191 "33\r"
-
- MatchStr 16 91 "6\r"
- MatchStr 17 92 "7\r"
- MatchStr 18 93 "3\r"
- MatchStr 19 94 "8\r"
-
- @Label 191
- MatchRead 1200
- SetVar A "NONE"
- return
-
- @Label 192
- Note "Ring…"
- Jump 191
-
- @Label 193
- SetVar C "REL"
- Jump 181
-
- @Label 194
- SetVar B "2400"
- Jump 191
- @Label 195
- SetVar B "4800"
- Jump 191
- @Label 196
- SetVar B "7200"
- Jump 191
- @Label 197
- SetVar B "9600"
- Jump 191
- @Label 198
- SetVar B "12000"
- Jump 191
- @Label 199
- SetVar B "14400"
- Jump 191
-
- @Label 200
- SetVar A "Data"
- return
-
- @Label 201
- SetVar A "Fax1"
- return
-